﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="taxi.aspx.cs" Inherits="admin_taxi"
    MasterPageFile="../MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="SheetHeaderPlaceHolder" runat="Server">

    Welcome</asp:Content>


<asp:Content ID="SheetContent" ContentPlaceHolderID="SheetContentPlaceHolder" runat="Server">

    &nbsp;<asp:HiddenField ID="HiddenField1" runat="server" Value="ok" />
    <div id="popCT"
    style="visibility:hidden;">
    <div id="popBg" style="width: 135%; height: 75%; position: absolute;background-color: #151613;
    filter:alpha(opacity=50);-moz-opacity:0.5;-khtml-opacity: 0.5;opacity: 0.5;""></div>
        <div style="position: absolute; width: 250px; height: 200px; top: 120px; left: 50%;">
    <asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" 
            DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="CityID" 
            Width="95%" onselectedindexchanged="DropDownList4_SelectedIndexChanged">
    </asp:DropDownList><br />
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:conn %>" 
            SelectCommand="SELECT [CityID], [Name] FROM [City]"></asp:SqlDataSource>
        <asp:DropDownList ID="town_drp" runat="server" 
            DataSourceID="SqlDataSource3" DataTextField="Name" DataValueField="TownID" 
            Width="95%" ClientIDMode="Static">
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:conn %>" 
            SelectCommand="SELECT [Name], [TownID] FROM [Town] WHERE ([CityID] = @CityID)">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList4" Name="CityID" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <input id="Button2" title="OK" type="button" value="OK" onclick="hidePopCT()"/></div></div>
    <script type="text/javascript"> showPopCT();</script>
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="ID" 
        DataSourceID="SqlDataSource1" onitemupdated="ListView1_ItemUpdated">
        <AlternatingItemTemplate>
            <tr style="background-color: #FAFAD2; color: #284775;">
                <td>
                    <asp:Label ID="PlateNoLabel" runat="server" Text='<%# Eval("PlateNo") %>' />
                </td>
                <td>
                    <asp:Label ID="DailyKmLabel" runat="server" Text='<%# Eval("DailyKm") %>' />
                </td>
                <td>
                    <asp:Label ID="TotalKmLabel" runat="server" Text='<%# Eval("TotalKm") %>' />
                </td>
                <td>
                    <asp:Label ID="RevenueLabel" runat="server" Text='<%# Eval("Revenue") %>' />
                </td>
                <td>
                    <asp:Label ID="AvailableLabel" runat="server" Text='<%# Eval("Available") %>' />
                </td>
                <td>
                    <asp:Label ID="MaxKmLimitLabel" runat="server" Text='<%# Eval("MaxKmLimit") %>' />
                </td>
                <td>
                    <asp:Label ID="Label1" runat="server" Text='<%# ((bool)Eval("DayNight"))? "Night" :"Day"%>'></asp:Label>
                </td>
                <td>
                    <asp:Label ID="CustomerArriveTimeLabel" runat="server" Text='<%# Eval("CustomerArriveTime") %>' />
                </td>
                <td>
                    <asp:Label ID="DriverIDLabel" runat="server" Text='<%# Profile.GetProfile(Eval("DriverUserName").ToString()).FirstName + " " +Profile.GetProfile(Eval("DriverUserName").ToString()).LastName %>' />
                </td>
                <td>
                    <asp:Label ID="CurrentLocationLabel" runat="server" Text='<%# Eval("CityName") %>' />
                </td>
                <td>
                    <asp:Button ID="Button1" runat="server" Text="Edit" CommandName="Edit" />
                </td>
        </AlternatingItemTemplate>
        <EditItemTemplate>
            <tr style="background-color: #FFCC66; color: #000080;">
                <td>
                    <asp:Label ID="PlateNoLabel" runat="server" Text='<%# Eval("PlateNo") %>' />
                </td>
                <td>
                    <asp:Label ID="DailyKmLabel" runat="server" Text='<%# Eval("DailyKm") %>' />
                </td>
                <td>
                    <asp:Label ID="TotalKmLabel" runat="server" Text='<%# Eval("TotalKm") %>' />
                </td>
                <td>
                    <asp:Label ID="RevenueLabel" runat="server" Text='<%# Eval("Revenue") %>' />
                </td>
                <td>
                    <asp:DropDownList ID="DropDownList3" runat="server" DataValueField="Available" SelectedValue='<%# Bind("Available")%>'>
                        <asp:ListItem Value="ok     ">OK</asp:ListItem>
                        <asp:ListItem Value="busy   ">Busy</asp:ListItem>
                        <asp:ListItem Value="service">Service</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:TextBox ID="MaxKmLimitTextBox" runat="server" Text='<%# Bind("MaxKmLimit") %>'
                        Width="95%" />
                </td>
                <td>
                    <asp:DropDownList ID="DropDownList1" runat="server" Width="95%" SelectedValue='<%# Bind("DayNight")%>'
                        DataValueField="DayNight">
                        <asp:ListItem Value="False">Day</asp:ListItem>
                        <asp:ListItem Value="True">Night</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:TextBox ID="CustomerArriveTimeTextBox" runat="server" Text='<%# Bind("CustomerArriveTime") %>'
                        Width="95%" />
                </td>
                <td>
                    <asp:DropDownList ID="DropDownList2" runat="server" Width="95%" DataSourceID="driverDataSource"
                        DataValueField="UserName" DataTextField="UserName" SelectedValue='<%# Bind("DriverUserName")%>'>
                    </asp:DropDownList>
                    <asp:SqlDataSource runat="server" ID="driverDataSource" SelectCommand="SELECT dbo.Driver.UserName FROM dbo.Driver"
                        ConnectionString="<%$ ConnectionStrings:conn %>"></asp:SqlDataSource>
                </td>
                <td>
                    <asp:HiddenField ID="townid" runat="server" Value='<%# Bind("CurrentLocation")%>' ClientIDMode="Static"/>

                    <input id="openPop" type="button" value='<%# Eval("CityName") %>' onclick="isPostBack=true;showPopCT();"
                    runat="server"  ClientIDMode="Static" width="95%" style="width: 95%" />
                </td>
                
                <td>
                   
                    <asp:ImageButton ID="ImageButton1" runat="server" CommandName="Update" ImageUrl="../images/bt_ok.png"
                        onmouseover="this.src='../images/bt_ok2.png'" onmouseout="this.src='../images/bt_ok.png'" />
                    <asp:ImageButton ID="ImageButton2" runat="server" CommandName="Cancel" ImageUrl="~/images/bt_close2.png"
                        onmouseover="this.src='../images/bt_close.png'" onmouseout="this.src='../images/bt_close2.png'" />
                </td>
            </tr>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <table id="Table1" runat="server" style="background-color: #FFFFFF; border-collapse: collapse;
                border-color: #999999; border-style: none; border-width: 1px;">
                <tr>
                    <td>
                        No data was returned.
                    </td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <InsertItemTemplate>
            <tr style="">
                <td>
                    <asp:TextBox ID="PlateNoTextBox" runat="server" Text='<%# Bind("PlateNo") %>' />
                </td>
                <td>
                    <asp:TextBox ID="DailyKmTextBox" runat="server" Text='<%# Bind("DailyKm") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TotalKmTextBox" runat="server" Text='<%# Bind("TotalKm") %>' />
                </td>
                <td>
                    <asp:TextBox ID="RevenueTextBox" runat="server" Text='<%# Bind("Revenue") %>' />
                </td>
                <td>
                    <asp:TextBox ID="AvailableTextBox" runat="server" Text='<%# Bind("Available") %>' />
                </td>
                <td>
                    <asp:TextBox ID="MaxKmLimitTextBox" runat="server" Text='<%# Bind("MaxKmLimit") %>' />
                </td>
                <td>
                    <asp:Label ID="Label1" runat="server" Text='<%# ((bool)Eval("DayNight"))? "Night" :"Day"%>'></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="CustomerArriveTimeTextBox" runat="server" Text='<%# Bind("CustomerArriveTime") %>' />
                </td>
                <td>
                    <asp:TextBox ID="DriverSSNTextBox" runat="server" Text='<%# Bind("DriverSSN") %>' />
                </td>
                <td>
                    <asp:DropDownList ID="DropDownList1" runat="server">
                    </asp:DropDownList>
                    <asp:TextBox ID="CurrentLocationTextBox" runat="server" Text='<%# Bind("CurrentLocation") %>' />
                </td>
                <td>
                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                </td>
            </tr>
        </InsertItemTemplate>
        <ItemTemplate>
            <tr style="background-color: #FFFBD6; color: #333333;">
                <td>
                    <asp:Label ID="PlateNoLabel" runat="server" Text='<%# Eval("PlateNo") %>' />
                </td>
                <td>
                    <asp:Label ID="DailyKmLabel" runat="server" Text='<%# Eval("DailyKm") %>' />
                </td>
                <td>
                    <asp:Label ID="TotalKmLabel" runat="server" Text='<%# Eval("TotalKm") %>' />
                </td>
                <td>
                    <asp:Label ID="RevenueLabel" runat="server" Text='<%# Eval("Revenue") %>' />
                </td>
                <td>
                    <asp:Label ID="AvailableLabel" runat="server" Text='<%# Eval("Available") %>' />
                </td>
                <td>
                    <asp:Label ID="MaxKmLimitLabel" runat="server" Text='<%# Eval("MaxKmLimit") %>' />
                </td>
                <td>
                    <asp:Label ID="Label1" runat="server" Text='<%# ((bool)Eval("DayNight"))? "Night" :"Day"%>'></asp:Label>
                </td>
                <td>
                    <asp:Label ID="CustomerArriveTimeLabel" runat="server" Text='<%# Eval("CustomerArriveTime") %>' />
                </td>
                <td>
                    <asp:Label ID="DriverIDLabel" runat="server" Text='<%# Profile.GetProfile(Eval("DriverUserName").ToString()).FirstName + " " +Profile.GetProfile(Eval("DriverUserName").ToString()).LastName %>' />
                </td>
                <td>
                    <asp:Label ID="CurrentLocationLabel" runat="server" Text='<%# Eval("CityName") %>' />
                </td>
                <td>
                    <asp:Button ID="Button1" runat="server" Text="Edit" CommandName="Edit" />
                </td>
            </tr>
        </ItemTemplate>
        <LayoutTemplate>
            <table id="Table2" runat="server" width="850" class="taxilist">
                <tr id="Tr1" runat="server">
                    <td id="Td1" runat="server">
                        <table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;
                            border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;
                            font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <tr id="Tr2" runat="server" style="background-color: #FFFBD6; color: #333333;">
                                <th id="Th1" runat="server" width="70">
                                    Plate No
                                </th>
                                <th id="Th2" runat="server" width="60">
                                    Daily Km
                                </th>
                                <th id="Th3" runat="server" width="60">
                                    Total Km
                                </th>
                                <th id="Th4" runat="server" width="60">
                                    Revenue
                                </th>
                                <th id="Th5" runat="server" width="75">
                                    Available
                                </th>
                                <th id="Th6" runat="server" width="60">
                                    Max Km Limit
                                </th>
                                <th id="Th7" runat="server" width="60">
                                    Day Night
                                </th>
                                <th id="Th8" runat="server" width="130">
                                    Customer Arrive Time
                                </th>
                                <th id="Th9" runat="server" width="130">
                                    Driver SSN
                                </th>
                                <th id="Th10" runat="server" width="100">
                                    Current Location
                                </th>
                                <th id="Th11" runat="server" width="45">
                                </th>
                            </tr>
                            <tr id="itemPlaceholder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr id="Tr3" runat="server">
                    <td id="Td2" runat="server" style="text-align: center; background-color: #FFCC66;
                        font-family: Verdana, Arial, Helvetica, sans-serif; color: #333333;">
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <tr style="background-color: #FFCC66; font-weight: bold; color: #000080;">
                <td>
                    <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
                </td>
                <td>
                    <asp:Label ID="PlateNoLabel" runat="server" Text='<%# Eval("PlateNo") %>' />
                </td>
                <td>
                    <asp:Label ID="DailyKmLabel" runat="server" Text='<%# Eval("DailyKm") %>' />
                </td>
                <td>
                    <asp:Label ID="TotalKmLabel" runat="server" Text='<%# Eval("TotalKm") %>' />
                </td>
                <td>
                    <asp:Label ID="RevenueLabel" runat="server" Text='<%# Eval("Revenue") %>' />
                </td>
                <td>
                    <asp:Label ID="AvailableLabel" runat="server" Text='<%# Eval("Available") %>' />
                </td>
                <td>
                    <asp:Label ID="MaxKmLimitLabel" runat="server" Text='<%# Eval("MaxKmLimit") %>' />
                </td>
                <td>
                    <asp:CheckBox ID="DayNightCheckBox" runat="server" Checked='<%# Eval("DayNight") %>'
                        Enabled="false" />
                </td>
                <td>
                    <asp:Label ID="CustomerArriveTimeLabel" runat="server" Text='<%# Eval("CustomerArriveTime") %>' />
                </td>
                <td>
                    <asp:Label ID="DriverSSNLabel" runat="server" Text='<%# Eval("DriverSSN") %>' />
                </td>
                <td>
                    <asp:Label ID="CurrentLocationLabel" runat="server" Text='<%# Eval("CurrentLocation") %>' />
                </td>
            </tr>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:HiddenField ID="HiddenField2" runat="server" Value="ok" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>"
        DeleteCommand="DELETE FROM [Taxi] WHERE [ID] = @ID" InsertCommand="INSERT INTO [Taxi] ([PlateNo], [DailyKm], [TotalKm], [Revenue], [Available], [MaxKmLimit], [DayNight], [CustomerArriveTime], [DriverUserName], [CurrentLocation]) VALUES (@PlateNo, @DailyKm, @TotalKm, @Revenue, @Available, @MaxKmLimit, @DayNight, @CustomerArriveTime, @DriverUserName, @CurrentLocation)"
        SelectCommand="SELECT dbo.Taxi.ID, dbo.Taxi.PlateNo, dbo.Taxi.DailyKm, dbo.Taxi.TotalKm, dbo.Taxi.Revenue, dbo.Taxi.Available, dbo.Taxi.MaxKmLimit, dbo.Taxi.DayNight, dbo.Taxi.CustomerArriveTime, dbo.Taxi.DriverUserName, dbo.Taxi.CurrentLocation, dbo.Town.Name AS CityName FROM dbo.Taxi INNER JOIN dbo.Town ON dbo.Taxi.CurrentLocation = dbo.Town.TownID INNER JOIN dbo.Driver ON dbo.Taxi.DriverUserName = dbo.Driver.UserName WHERE (dbo.Driver.UserName = @Driver)"
        
        UpdateCommand="UPDATE [Taxi] SET [Available] = @Available, [MaxKmLimit] = @MaxKmLimit, [DayNight] = @DayNight, [CustomerArriveTime] = @CustomerArriveTime, [DriverUserName] = @DriverUserName, [CurrentLocation] = @CurrentLocation WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="PlateNo" Type="String" />
            <asp:Parameter Name="DailyKm" Type="Int32" />
            <asp:Parameter Name="TotalKm" Type="Int32" />
            <asp:Parameter Name="Revenue" Type="Double" />
            <asp:Parameter Name="Available" Type="String" />
            <asp:Parameter Name="MaxKmLimit" Type="Int32" />
            <asp:Parameter Name="DayNight" Type="Boolean" />
            <asp:Parameter DbType="Date" Name="CustomerArriveTime" />
            <asp:Parameter Name="DriverUserName" Type="String" />
            <asp:Parameter Name="CurrentLocation" Type="Int32" />
        </InsertParameters>
        <SelectParameters>
            <asp:ProfileParameter Name="Driver" PropertyName="UserName" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Available" Type="String" />
            <asp:Parameter Name="MaxKmLimit" Type="Int32" />
            <asp:Parameter Name="DayNight" Type="Boolean" />
            <asp:Parameter DbType="Date" Name="CustomerArriveTime" />
            <asp:Parameter Name="DriverUserName" Type="String" />
            <asp:Parameter Name="CurrentLocation" Type="Int32" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
     
</asp:Content>
